﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Persons.aspx.cs" Inherits="IMPPFront.Persons" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var prepare = function (grid, toolbar, rowIndex, record) {
            var gotoPPButton = toolbar.items.get(0);
            var addPPButton = toolbar.items.get(1);

            if (record.data.HasPP) {
                addPPButton.setDisabled(true);
                addPPButton.setTooltip("Deze persoon heeft al een persoonlijk plan.");
            } else {
                gotoPPButton.setDisabled(true);
                gotoPPButton.setTooltip("Deze persoon heeft nog geen persoonlijk plan.");
            }

            //you can return false to cancel toolbar for this record
        };       
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ext:Panel ID="CenterPanel" runat="server" AutoScroll="true" Border="false" Padding="10">
            <Items>
                <ext:Image runat="server" ImageUrl="~/Images/LogoHH.png" Width="192" />
                <ext:GridPanel runat="server" ID="PersonsGrid" Frame="true" Title="Medewerkers" Border="true" AutoHeight="true" AutoScroll="true">
                    <TopBar>
                        <ext:Toolbar ID="FilterToolBar" runat="server">
                            <Items>
                                <ext:TextField runat="server" ID="tfFilter" FieldLabel="Filter"  AutoWidth="true" />
                                <ext:Button runat="server" ID="btnFilter" Icon="Reload" Text="Filter!" OnDirectClick="FilterGrid" />
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store runat="server" ID="PersonsStore" RemoteSort="true" OnRefreshData="Persons_RefreshData">
                            <Proxy>
                                <ext:PageProxy />
                            </Proxy>
                            <Reader>
                                <ext:JsonReader IDProperty="idNaturalPerson">
                                    <Fields>
                                        <ext:RecordField Name="idNaturalPerson" Type="Int" />
                                        <ext:RecordField Name="FirstName" Type="String" />
                                        <ext:RecordField Name="LastName" Type="String" />
                                        <ext:RecordField Name="HasPP" Type="Boolean" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                            <BaseParams>
                                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                                <ext:Parameter Name="limit" Value="20" Mode="Raw" />
                                <ext:Parameter Name="sort" Value="" />
                                <ext:Parameter Name="dir" Value="" />
                            </BaseParams>
                            <SortInfo Field="Id" Direction="ASC" />
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="PersonColumnModel" runat="server">
			            <Columns>
                            <ext:Column Header="Id" DataIndex="idNaturalPerson" />
                            <ext:Column Header="Voornaam" DataIndex="FirstName" />
                            <ext:Column Header="Familienaam" DataIndex="LastName" />
                            <ext:CommandColumn Width="120px">
                                <Commands>
                                    <ext:GridCommand Text="Persoonlijk plan" Icon="Book" />
                                </Commands>
                            </ext:CommandColumn>
			            </Columns>
                    </ColumnModel>
                    <LoadMask ShowMask="true" />
                    <Plugins>
                        <ext:GridFilters runat="server" ID="PersonsGridFilters">
                            <Filters>
                                <ext:NumericFilter DataIndex="idNaturalPerson" />
                                <ext:StringFilter DataIndex="Name.FirstName" />
                                <ext:StringFilter DataIndex="Name.LastName" />
                            </Filters>
                        </ext:GridFilters>
                    </Plugins>
                    <BottomBar>
                        <ext:PagingToolbar 
                            runat="server" 
                            PageSize="20" 
                            DisplayInfo="true"
                            DisplayMsg="Toont medewerkers {0} - {1} van de {2}" 
                            EmptyMsg="Geen medewerkers om te laten zien."
                            AnchorHorizontal="95%"                            
                            />
                    </BottomBar>
                    <DirectEvents>
                        <Command OnEvent="GotoPersoonlijkPlan">
                            <ExtraParams>
                                <ext:Parameter Name="id" Value="record.data.idNaturalPerson" Mode="Raw" />
                            </ExtraParams>
                        </Command>
                    </DirectEvents>
                </ext:GridPanel>
            </Items>
        </ext:Panel>
</asp:Content>
